<?php
namespace statistics\view\renderers;

use statistics\utils\PHPScriptExecutor;
use statistics\utils\AccessControlManager;
use statistics\view\renderers\ElementRenderer;

require_once(substr(__DIR__, 0, strpos(__DIR__, 'statistics')+10). DIRECTORY_SEPARATOR .'includes.php');


class StandardPageRenderer extends AbstractPageRenderer{
	

	
	public function __construct($pageTitle){
		parent::__construct($pageTitle);				
		$this->pageHeader = '';
		$this->onLoadActions = '';
	}
	
	private function initializePage(){
		global $gLayout;
				
		$gLayout['title']  = $this->pageTitle;
		$gLayout['header'] = $this->pageHeader;
		$gLayout['onload'] = $this->onLoadActions;		
		
	}
			
	public function renderElement(){
		
		$this->initializePage();
		
		$this->renderedElementHTML .= PHPScriptExecutor::getScriptOutput(SERVER_PATH. '/adm_program/system/overall_header.php');			
							
 		$this->renderElementContent();				
		
		$this->renderedElementHTML .= $this->generateBackButton();
		
		$this->renderedElementHTML .= PHPScriptExecutor::getScriptOutput(SERVER_PATH. '/adm_program/system/overall_footer.php');
	}
	
	private function generateBackButton(){
		global $g_root_path;
		global $gL10n;
		
		return '
        <ul class="iconTextLinkList">
            <li>
                <span class="iconTextLink">
                <span class="iconTextLink">
                    <a href="'.$g_root_path.'/adm_program/system/back.php"><img
                    src="'. THEME_PATH. '/icons/back.png" alt="'.$gL10n->get('SYS_BACK').'" /></a>
                    <a href="'.$g_root_path.'/adm_program/system/back.php">'.$gL10n->get('SYS_BACK').'</a>
                </span>
            </li>
        </ul>';
	}
	
	public function addPageHeader($header){
		$this->pageHeader .= $header;
	}
	
	public function addOnLoadAction($action){
		$this->onLoadActions .= $action;
	}
	
}

?>